<?php
require_once(dirname(__FILE__).'/appconf.php');

class Test extends Site{
	function setup(){
		$this->run_modes('def','test');
		$this->start_mode('def');
		$this->selfurl = '/test.php';
		parent::setup();
	}

	function cgiapp_prerun($rm=''){
		//$this->Product = getModel('Model_Product');
		parent::cgiapp_prerun();
	}

	function action_def(){
	return $this->load_tmpl("hong_test.php");
	}
	function action_test(){
	
        $id = intval($this->get_q('id', 1, 'int'));
		$s = db_query_one('product',array('field'=>'id,click','where'=>'id=1'));
		$_c_res = db_handle('update product set click=click+1 where id='.$id);
		
        echo $bb = $_c_res > 0 ? intval($s['result']['click']) + 1 : $s['result']['click'];
		$aa = db_query_one('product',array('field'=>'id,click','where'=>'id=1'));
		//echo '<pre>' . var_export($aa, 1) . '</pre>';
		$this->tmpl_assign('aa', var_export($aa, 1));
        return $this->load_tmpl("hong_test.php");
	}
}
$webapp = new Test();
$webapp->run();
?>